<template>
  <RouterView />
</template>

<script setup lang="ts">
import { RouterView } from 'vue-router'
import { onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'

function isMobileDevice() {
  return /Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
}

onMounted(() => {
  // 检测是否是手机端
  if (isMobileDevice()) {
    let msg = '检测你使用移动设备访问，点击确定跳转至移动专用站点'
    let site = 'https://m.kmdc.org.cn'
    ElMessageBox.confirm(msg)
      .then(() => {
        window.location.href = 'https://m.kmdc.org.cn'
      })
      .finally(() => {
        window.location.href = site
      })
    console.log('这是一个手机端设备')
  }
})
</script>

<style scoped></style>
